package com.ccp.dev.qbdms.controller;

import static com.ccp.dev.qbdms.consts.ZhiLiangConst.GROUP_ALREADY_SEND3;
import static com.ccp.dev.qbdms.consts.ZhiLiangConst.GROUP_FAILURE_SEND2;
import static com.ccp.dev.qbdms.consts.ZhiLiangConst.GROUP_LOADING_SEND;
import static com.ccp.dev.qbdms.consts.ZhiLiangConst.GROUP_PREPARE_SEND;
import static com.ccp.dev.qbdms.consts.ZhiLiangConst.GROUP_REVIEW;
import static com.ccp.dev.qbdms.consts.ZhiLiangConst.HAIR_DOWN_MAP;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.api.ISysUser;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.response.ResultData;
import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.util.BeanUtils;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.util.TimeUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.extend.service.ExtendSysOrgService;
import com.ccp.dev.form.service.impl.ScriptImpl;
import com.ccp.dev.qbdms.consts.ZhiLiangConst;
import com.ccp.dev.qbdms.expimp.util.AbstractExpUtil;
import com.ccp.dev.qbdms.expimp.util.AuxiliaryUtil;
import com.ccp.dev.qbdms.model.WFlightRewardsProject;
import com.ccp.dev.qbdms.model.WQbdFlightJc;
import com.ccp.dev.qbdms.model.WQbdFlightJcjlcf;
import com.ccp.dev.qbdms.model.WQbdFlightJczb;
import com.ccp.dev.qbdms.model.WQbdXhdh;
import com.ccp.dev.qbdms.model.WRewardsMoneyAllocation;
import com.ccp.dev.qbdms.model.vo.WFlightRewardsProjectVo;
import com.ccp.dev.qbdms.model.vo.WQbdFlightJcGroupVo;
import com.ccp.dev.qbdms.model.vo.WQbdFlightJcJHBSJLVo;
import com.ccp.dev.qbdms.model.vo.WQbdFlightJcLevelSecondVo;
import com.ccp.dev.qbdms.model.vo.WQbdFlightJcjlcfParamVo;
import com.ccp.dev.qbdms.service.WFlightRewardsProjectService;
import com.ccp.dev.qbdms.service.WQbdFlightJcService;
import com.ccp.dev.qbdms.service.WQbdFlightJcjlcfService;
import com.ccp.dev.qbdms.service.WQbdFlightJczbService;
import com.ccp.dev.qbdms.service.WQbdXhdhService;
import com.ccp.dev.qbdms.service.WRewardsMoneyAllocationService;
import com.ccp.dev.qbdms.util.BaseUtil;
import com.ccp.dev.qbdms.util.BaseUtil.SystemLevel;
import com.ccp.dev.qbdms.util.ProjectUUIDUtils;
import com.ccp.dev.qbdms.util.StructureModifyUtil;
import com.ccp.dev.system.model.Dictionary;
import com.ccp.dev.system.model.SysOrg;
import com.ccp.dev.system.service.DictionaryService;
import com.ccp.dev.system.service.SysOrgService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 飞行试验奖惩管理 信息操作处理控制器
 *
 * @author 于金
 * @date 2020-05-25 16:46:07
 */
@Controller
/**
 * 请将此名称添加到日志开关
 */
@Action(customModel = "飞行试验奖惩管理")
@RequestMapping("/qbdms/wQbdFlightJc")
public class WQbdFlightJcController extends SysBaseController {

	@Resource
	private WQbdFlightJcService wQbdFlightJcService;
	@Resource
	private WQbdFlightJczbService wQbdFlightJczbService;
	@Resource
	private WQbdXhdhService wQbdXhdhService;
	@Resource
	private WQbdFlightJcjlcfService wQbdFlightJcjlcfService;
	@Resource
	private ScriptImpl scriptImpl;
	@Resource
	private SysOrgService sysOrgService;

	/**
	 * 功能描述: 跳转到首页
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_LIST)
	@Action(description = "跳转到飞行试验奖惩管理首页", exectype = "页面跳转日志")
	public String viewList(ModelMap modelMap) {
		String userId = ContextUtil.getCurrentUserId();
		modelMap.put("userId",userId);
		setDicToModelMap("ztdwmc",modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
		setDicToModelMap("zt", modelMap);
		return "wQbdFlightJc/list";
	}
	@Resource
	private ScriptImpl script;
	/**
	 * 功能描述: 附带检索条件的分页查询
	 *
	 * @param: [request] http请求
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.MODULE_FUNCTION_LIST)
	@ResponseBody
	@Action(description = "附带检索条件的分页查询飞行试验奖惩管理", detail = "查询数据信息<#if success>成功<#else></#if>")
	public Object list(HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, true);
		ZhiLiangConst.addQueryFilterNoReportStatus(queryFilter);
		List<WQbdFlightJc> pageDatas = wQbdFlightJcService.queryList(queryFilter);
//		总体单位名称
		List<Dictionary> ztdwmcList = dictionaryService.getDicByNodeKey("ztdwmc", false);
		pageDatas.stream().forEach(wQbdFlightJc -> {
			try {
				ztdwmcList.forEach(a->{
					if(a.getItemValue().equals(wQbdFlightJc.getZtswmc())){
						wQbdFlightJc.setZtswmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		pageDatas.stream().forEach(wQbdFlightJc -> {
			try {
				xhmcList.forEach(a->{
					if(a.getItemValue().equals(wQbdFlightJc.getXhmc())){
						wQbdFlightJc.setXhmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

		SysAuditThreadLocalHolder.putParamerter("success", true);
		return success(pageDatas, queryFilter.getPageBean().getTotalCount());
	}

	@Resource
	private ExtendSysOrgService extendSysOrgService;

	public List<Dictionary> getOriginOrgToDicList() {
		List<SysOrg> sysOrgList = extendSysOrgService.getSubLevelOrg();
		sysOrgList = sysOrgList.stream().filter(sysOrg -> sysOrg.getIsTenant() == 1)
				.collect(Collectors.toList());
		List<Dictionary> dicList = new ArrayList<>();
		for (SysOrg sysOrg : sysOrgList) {
			Dictionary dictionary = new Dictionary();
			dictionary.setItemName(sysOrg.getOrgName());
			dictionary.setItemValue(sysOrg.getCode());
			dicList.add(dictionary);
		}
		return dicList;
	}

	/**
	 * 功能描述: 计划编制
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_ADD_UPDATE)
	@Action(description = "跳转到飞行试验奖惩管理计划编制页面", exectype = "页面跳转日志")
	public String viewAdd(HttpServletRequest request, ModelMap modelMap) {
		String id = RequestUtil.getString(request, "id");
		QueryFilter queryFilter = new QueryFilter(request,false);
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WFlightRewardsProjectVo> Projects = wFlightRewardsProjectService.getFxsymcList(queryFilter);
		modelMap.put("projectList", JSON.toJSONString(Projects));
		List<Dictionary> originOrgToDicList = getOriginOrgToDicList();
		modelMap.put("id", id);
		//        密级
		setDicToModelMap("mj", modelMap);
		//型号名称
//		setDicToModelMap("xhmc", modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
//       项目类型
		setDicToModelMap("xmlx", modelMap);
//       总体单位名称
		setDicToModelMap("ztdwmc", modelMap);
//       项目类别
		setDicToModelMap("xmlb", modelMap);
//       项目阶段
		setDicToModelMap("xmjd", modelMap);
//       主管部门
		setDicToModelMap("zgbm", modelMap);
//       单位类别
		setDicToModelMap("dwlb", modelMap);

//       单位类别
		setDicToModelMap("swlb", modelMap);

		if (StringUtil.isEmpty(id)) {
			modelMap.put("filldept", ContextUtil.getCurrentOrg().getOrgName());
			modelMap.put("fillman", ContextUtil.getCurrentUser().getFullName());
			modelMap.put("filldate", TimeUtil.getCurrentDate());
		}

		return "wQbdFlightJc/add";
	}

	/**
	 * 功能描述: 跳转到编辑页面
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/edit")
	@Action(description = "跳转到飞行试验奖惩管理编辑页面", exectype = "页面跳转日志")
	public String viewEdit(HttpServletRequest request, ModelMap modelMap) {
		String id = RequestUtil.getString(request, "id");
		if (StringUtil.isEmpty(id)) {
			modelMap.put("filldept", ContextUtil.getCurrentOrg().getOrgName());
			modelMap.put("fillman", ContextUtil.getCurrentUser().getFullName());
			modelMap.put("filldate", TimeUtil.getCurrentDate());
		}
		QueryFilter queryFilter = new QueryFilter(request,false);
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WFlightRewardsProjectVo> Projects = wFlightRewardsProjectService.getFxsymcList(queryFilter);
		modelMap.put("projectList", JSON.toJSONString(Projects));
		List<Dictionary> originOrgToDicList = getOriginOrgToDicList();
		modelMap.put("id", id);
		//        密级
		setDicToModelMap("mj", modelMap);
		//型号名称
//		setDicToModelMap("xhmc", modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
//       项目类型
		setDicToModelMap("xmlx", modelMap);
//       总体单位名称
//		modelMap.put("ztdwmcList", JSON.toJSONString(originOrgToDicList));
		setDicToModelMap("ztdwmc", modelMap);
//       项目类别
		setDicToModelMap("xmlb", modelMap);
//       项目阶段
		setDicToModelMap("xmjd", modelMap);
//       主管部门
		setDicToModelMap("zgbm", modelMap);
//       单位类别
		setDicToModelMap("dwlb", modelMap);

//       单位类别
		setDicToModelMap("swlb", modelMap);

		return "wQbdFlightJc/edit";
	}
	/**
	 * 功能描述: 跳转到编审记录页面
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX +"/bsjl")
	@Action(description = "跳转到编审记录页面", exectype = "页面跳转日志")
	public String bsjl(HttpServletRequest request, ModelMap modelMap) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
		String id = RequestUtil.getString(request, "id");
		QueryFilter queryFilter = new QueryFilter(request,false);
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WFlightRewardsProjectVo> Projects = wFlightRewardsProjectService.getFxsymcList(queryFilter);
		modelMap.put("projectList", JSON.toJSONString(Projects));
		List<Dictionary> originOrgToDicList = getOriginOrgToDicList();
		modelMap.put("id", id);
		//        密级
		setDicToModelMap("mj", modelMap);
		//型号名称
//		setDicToModelMap("xhmc", modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
//       项目类型
		setDicToModelMap("xmlx", modelMap);
//       总体单位名称
//		modelMap.put("ztdwmc", modelMap);
		setDicToModelMap("ztdwmc", modelMap);
//       项目类别
		setDicToModelMap("xmlb", modelMap);
//       项目阶段
		setDicToModelMap("xmjd", modelMap);
//       主管部门
		setDicToModelMap("zgbm", modelMap);
//       单位类别
		setDicToModelMap("dwlb", modelMap);
//       单位类别
		setDicToModelMap("swlb", modelMap);
		//密级
		List<Dictionary> dicList = dictionaryService.getDicByNodeKey("mj", false);
		//总体单位名称
//		List<Dictionary> ztdwmcList = getOriginOrgToDicList();

		get(id,modelMap);
		WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(id);
		dicList.forEach(a->{
			if(a.getItemValue().equals(wQbdFlightJc.getSecret())){
				wQbdFlightJc.setSecret(a.getItemName());
			}
		});
		List<Dictionary> ztdwmcList = dictionaryService.getDicByNodeKey("ztdwmc", false);
		ztdwmcList.forEach(a->{
			if(a.getItemValue().equals(wQbdFlightJc.getZtswmc())){
				wQbdFlightJc.setZtswmc(a.getItemName());
			}
		});
		xhmcList.forEach(a->{
			if(a.getItemValue().equals(wQbdFlightJc.getXhmc())){
				wQbdFlightJc.setXhmc(a.getItemName());
			}
		});
		Map<String,Object> paramMap= Maps.newHashMap();
		paramMap.put("refId",wQbdFlightJc.getId());
		paramMap.put("tableName","W_QBD_FLIGHT_JCZB");
		List<WQbdFlightJczb>  wQbdFlightJczbs=wQbdFlightJczbService.getListByRefId(paramMap);
		wQbdFlightJczbs.forEach(s->{
			SysOrg org = sysOrgService.getSysOrgByOrgCode(s.getJlswmc());
			s.setJlswmc(org.getOrgName());
		});
		wQbdFlightJc.setwQbdFlightJczbList(wQbdFlightJczbs);
		modelMap.addAttribute("wQbdFlightJczbs",wQbdFlightJczbs);



		modelMap.addAttribute("data", wQbdFlightJc);
		//项目表
		String fxsyxmId = wQbdFlightJcService.getOneById(id).getFxsyxmId();
		WFlightRewardsProject rewardsProject = wFlightRewardsProjectService.getOneById(fxsyxmId);

		dicList.forEach(a->{
			if(a.getItemValue().equals(rewardsProject.getSecret())){
				rewardsProject.setSecret(a.getItemName());
			}
		});

		ztdwmcList.forEach(a->{
			if(a.getItemValue().equals(rewardsProject.getTotalityunitname())){
				rewardsProject.setTotalityunitname(a.getItemName());
			}
		});
		xhmcList.forEach(a->{
			if(a.getItemValue().equals(rewardsProject.getModelname())){
				rewardsProject.setModelname(a.getItemName());
			}
		});

		List<WRewardsMoneyAllocation> allocationList = wRewardsMoneyAllocationService.getListByRefIdBS(fxsyxmId);
		allocationList.forEach(s->{
			SysOrg org = sysOrgService.getSysOrgByOrgCode(s.getRewardsUnitName());
			s.setRewardsUnitName(org.getOrgName());
		});
		modelMap.addAttribute("rewardsProject",rewardsProject);
		modelMap.addAttribute("allocationList", allocationList);


		int n=wQbdFlightJczbs.size();
		int m =allocationList.size();
		int d=n>m?n:m;
		List<WQbdFlightJcJHBSJLVo> list=new ArrayList<>();
		for (int i=0;i<d;i++){
			WQbdFlightJczb a = wQbdFlightJczbs.get(i);
			WRewardsMoneyAllocation b = allocationList.get(i);
			WQbdFlightJcJHBSJLVo c=new WQbdFlightJcJHBSJLVo();
		    BeanUtils.copyNotNullProperties(c,a);
			BeanUtils.copyNotNullProperties(c,b);
			list.add(c);
		}

		modelMap.addAttribute("c", list);
		return "wQbdFlightJc/bsjl";
	}
	public List<Dictionary> getXhdhToDicList(){
		List<WQbdXhdh> xhdhList = wQbdXhdhService.getAll();
		List<Dictionary> dicList = new ArrayList<>();
		for(WQbdXhdh wQbdXhdh : xhdhList){
			Dictionary dictionary = new Dictionary();
			dictionary.setItemName(wQbdXhdh.getfModelname());
			dictionary.setItemValue(wQbdXhdh.getfModelname());
			dicList.add(dictionary);
		}
		return dicList;
	}


	@Resource
	private DictionaryService dictionaryService;

	private void setDicToModelMap(String key, ModelMap modelMap) {
		List<Dictionary> dicList = dictionaryService.getDicByNodeKey(key, false);
		modelMap.put(key + "List", JSON.toJSONString(dicList));
	}

	/**
	 * 功能描述:  数据保存通用方法
	 *
	 * @param: wQbdFlightJc 保存的对象
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.MODULE_FUNCTION_SAVE)
	@ResponseBody
	@Action(description = "保存飞行试验奖惩管理数据", detail = "<#if isAdd>新增<#else>编辑</#if>飞行试验奖惩管理数据<#if success>成功<#else>失败</#if><#if StringUtil.isNotEmpty(modifyInfo)>${modifyInfo}</#if>")
	public Object save(@RequestBody WQbdFlightJc wQbdFlightJc) {
		String id = wQbdFlightJc.getId();
		if (BeanUtils.isNotEmpty(wQbdFlightJc.getFj())){
			String fj =wQbdFlightJc.getFj().replaceAll("&quot;","\"");
			wQbdFlightJc.setFj(fj);
		}

		int result;
		if (StringUtil.isEmpty(id)) {
			SysAuditThreadLocalHolder.putParamerter("isAdd", true);
			wQbdFlightJc.setBelongdeptname(BaseUtil.getCurrentTenOrgCodePath());
			//新增操作
			//新增数据前生成随机Id
			wQbdFlightJc.setId(ProjectUUIDUtils.getUUIDFor32());
			wQbdFlightJc.setTenantId(ContextUtil.getCurrentUserTenantId());
			wQbdFlightJc.setCreateBy(ContextUtil.getCurrentUserId());
			wQbdFlightJc.setCreateTime(new Date());
			wQbdFlightJc.setStatus(HAIR_DOWN_MAP.get(GROUP_PREPARE_SEND));
//			更新是否被编制
			WFlightRewardsProject wFlightRewardsProject=new WFlightRewardsProject();
			wFlightRewardsProject.setId(wQbdFlightJc.getFxsyxmId());
			//编制
			wFlightRewardsProject.setIsbz("1");
			wFlightRewardsProjectService.updateisBz(wFlightRewardsProject);

			wQbdFlightJc.setFilldept(ContextUtil.getCurrentOrg().getOrgName());
			wQbdFlightJc.setFilldate(TimeUtil.getCurrentDate());
			wQbdFlightJc.setFillman(ContextUtil.getCurrentUser().getFullName());
			wQbdFlightJc.setFillmanaccount(ContextUtil.getCurrentUser().getAccount());
			wQbdFlightJc.setFilldeptid(((SysOrg) ContextUtil.getCurrentOrg()).getCode());
			wQbdFlightJc.setReportStatus(ZhiLiangConst.GROUP_CONFIRMED);
			result = wQbdFlightJcService.add(wQbdFlightJc);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			wQbdFlightJc.setUpdateBy(ContextUtil.getCurrentUserId());
			wQbdFlightJc.setUpdateTime(new Date());
			WQbdFlightJc flightJc = wQbdFlightJcService.getOneById(id);
			String modifyInfo = StructureModifyUtil.getModifyInfo(flightJc, wQbdFlightJc);
			SysAuditThreadLocalHolder.putParamerter("modifyInfo",modifyInfo);
			result = wQbdFlightJcService.update(wQbdFlightJc);
		}
		if (result > 0) {
			SysAuditThreadLocalHolder.putParamerter("success", true);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
		}
		return result > 0 ? getResultDataSuccess("save.success") : getResultDataError("save.failure");
	}

	/**
	 * 功能描述: 跳转到详情页面
	 *
	 * @return: java.lang.String
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/particulars")
	@Action(description = "跳转到飞行试验奖惩管理详情页面", exectype = "页面跳转日志")
	public String viewParticulars(HttpServletRequest request, ModelMap modelMap) {
		String id = RequestUtil.getString(request, "id");
		modelMap.put("id", id);
		QueryFilter queryFilter = new QueryFilter(request,false);
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WFlightRewardsProjectVo> Projects = wFlightRewardsProjectService.getFxsymcList(queryFilter);
		modelMap.put("projectList", JSON.toJSONString(Projects));
		List<Dictionary> originOrgToDicList = getOriginOrgToDicList();
		modelMap.put("id", id);
		//        密级
		setDicToModelMap("mj", modelMap);
//		//型号名称
//		setDicToModelMap("xhmc", modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
//       项目类型
		setDicToModelMap("xmlx", modelMap);
//       总体单位名称
		modelMap.put("ztdwmc", modelMap);
		setDicToModelMap("ztdwmc", modelMap);
//       项目类别
		setDicToModelMap("xmlb", modelMap);
//       项目阶段
		setDicToModelMap("xmjd", modelMap);
//       主管部门
		setDicToModelMap("zgbm", modelMap);
//       单位类别
		setDicToModelMap("dwlb", modelMap);

//       单位类别
		setDicToModelMap("swlb", modelMap);

		String isClose = RequestUtil.getString(request, "isClose");
		modelMap.put("isClose", isClose);

		return "wQbdFlightJc/particulars";
	}

	/**
	 * 功能描述: 根据主键id获取一条数据的通用查询方法
	 *
	 * @param: id 参数对象必须是"id"
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.MODULE_FUNCTION_GET)
	@ResponseBody
	@Action(description = "根据主键id查询飞行试验奖惩管理的一条数据", detail = "根据主键id查询飞行试验奖惩管理的数据<#if success>成功<#else>失败</#if>")
	public Object get(@RequestParam("id") String id, ModelMap modelMap) {
		WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(id);
		Map<String,Object> paramMap= Maps.newHashMap();
		paramMap.put("refId",wQbdFlightJc.getId());
		paramMap.put("tableName","W_QBD_FLIGHT_JCZB");
		List<WQbdFlightJczb>  wQbdFlightJczbs=wQbdFlightJczbService.getListByRefId(paramMap);
//		wQbdFlightJczbs.forEach(s->{
//			SysOrg org = sysOrgService.getSysOrgByOrgCode(s.getJlswmc());
//			s.setJlswmc(org.getOrgName());
//		});
		wQbdFlightJc.setwQbdFlightJczbList(wQbdFlightJczbs);
		if (null == wQbdFlightJc) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return getResultDataError("get.failure");
		}
		SysAuditThreadLocalHolder.putParamerter("success", true);
		modelMap.addAttribute("wQbdFlightJczbs",wQbdFlightJczbs);
		modelMap.addAttribute("data", wQbdFlightJc);
		return getResultDataSuccess("get.success", wQbdFlightJc);
	}

	@Resource
	private WFlightRewardsProjectService wFlightRewardsProjectService;
	@Resource
	private WRewardsMoneyAllocationService wRewardsMoneyAllocationService;

	/**
	 * 功能描述: 查找飞行试验项目管理列表并且自动回填数据
	 *
	 * @param: id 参数对象必须是"id"
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping("/getjhbz")
	@ResponseBody
	@Action(description = "根据主键id查询飞行试验奖惩管理的一条数据", detail = "根据主键id查询飞行试验奖惩管理的数据<#if success>成功<#else>失败</#if>")
	public Object getList(@RequestParam("id") String id) {
		WFlightRewardsProject flightRewardsProject = wFlightRewardsProjectService.getOneById(id);
		List<WQbdFlightJczb> listByRefId = wRewardsMoneyAllocationService.getListByRefIdJH(id);
//		listByRefId.forEach(WQbdFlightJczb -> {
//			BigDecimal divide = WQbdFlightJczb.getFpbl()
//					.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
//			WQbdFlightJczb.setFpbl(divide);
//		});
		if (null == flightRewardsProject) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return getResultDataError("get.failure");
		}
		flightRewardsProject.setwQbdFlightJczbList(listByRefId);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return getResultDataSuccess("get.success", flightRewardsProject);
	}

	/**
	 * 功能描述: 根据主键ID删除数据的通用删除方法
	 *
	 * @param: id 参数名称必须是"id"
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@PostMapping(UrlConstants.MODULE_FUNCTION_DELETE)
	@ResponseBody
	@Action(description = "根据主键ID删除飞行试验奖惩管理数据", exectype = "删除日志", detail = "删除数据信息<#if success>成功<#else>失败</#if>")
	public Object delete(@RequestParam("id") String id) {
		if (StringUtil.isEmpty(id)) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return fail("delete.failure.message");
		}
		String userId = ContextUtil.getCurrentUserId();
		String[] ids = id.split(",");
		for (String key : ids) {
			WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(key);
			if (Objects.nonNull(wQbdFlightJc.getStatus())
					&& !HAIR_DOWN_MAP.get(GROUP_PREPARE_SEND).equals(wQbdFlightJc.getStatus())) {
				SysAuditThreadLocalHolder.putParamerter("success", false);
				return fail("删除失败，只允许删除待下发的数据");
			}

			if (!userId.equals(wQbdFlightJc.getCreateBy())) {
				SysAuditThreadLocalHolder.putParamerter("success", false);
				return fail("删除失败，只能删除自己创建的数据！");
			}
		}
		int result = wQbdFlightJcService.delByIdArray(id.split(","));
		if (result > 0) {
			SysAuditThreadLocalHolder.putParamerter("success", true);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
		}
		return result > 0 ? getResultDataSuccess("delete.success")
				: getResultDataError("delete.failure");
	}

	/**
	 * 功能描述: 计划下发
	 *
	 * @param: id 参数名称必须是"id"
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@PostMapping("/xf")
	@ResponseBody
	@Action(description = "根据主键ID下发飞行试验奖惩管理数据", exectype = "计划下发", detail = "计划下发信息<#if success>成功<#else>失败</#if>")
	public Object xf(@RequestParam("id") String id) throws Exception {
		if (StringUtil.isEmpty(id)) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return fail("下发失败，未传入数据唯一标识!");
		}
		String userId = ContextUtil.getCurrentUserId();
		String[] ids = id.split(",");
		List<WQbdFlightJc> list = new ArrayList<>();
		for (String key : ids) {
			WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(key);
			Map<String,Object> paramMap= Maps.newHashMap();
			paramMap.put("refId",wQbdFlightJc.getId());
			paramMap.put("tableName","W_QBD_FLIGHT_JCZB");
			List<WQbdFlightJczb> listByRefId = wQbdFlightJczbService
					.getListByRefId(paramMap);
			wQbdFlightJc.setwQbdFlightJczbList(listByRefId);
			if (wQbdFlightJc.getStatus().equals(HAIR_DOWN_MAP.get(GROUP_PREPARE_SEND))) {
				wQbdFlightJc.setStatus(HAIR_DOWN_MAP.get(GROUP_LOADING_SEND));
				list.add(wQbdFlightJc);
				continue;
			}
			if (wQbdFlightJc.getStatus().equals(HAIR_DOWN_MAP.get(GROUP_FAILURE_SEND2))) {
				wQbdFlightJc.setStatus(HAIR_DOWN_MAP.get(GROUP_LOADING_SEND));
				list.add(wQbdFlightJc);
				continue;
			}
			if (wQbdFlightJc.getStatus().equals(HAIR_DOWN_MAP.get(GROUP_LOADING_SEND))) {
				return fail("下发失败,当前数据存在已经在下发的!");
			}
			if (wQbdFlightJc.getStatus().equals(HAIR_DOWN_MAP.get(GROUP_ALREADY_SEND3))) {
				return fail("下发失败，当前数据中存在已经下发的!");
			}
			if (wQbdFlightJc.getStatus().equals(HAIR_DOWN_MAP.get(GROUP_REVIEW))){
				return fail("下发失败，当前数据中存在已经审减的!");
			}
		}
//		下发中
		wQbdFlightJcService.updateStatus(list);
		//调用下发到院级单位数据接口
		boolean isSuccess=wQbdFlightJcService.reportSend(list);
//		boolean isSuccess=true;
		if (isSuccess) {
			for(WQbdFlightJc wQbdFlightJc:list){
				List<WQbdFlightJczb> wQbdFlightJczbList=wQbdFlightJc.getwQbdFlightJczbList();
				for(WQbdFlightJczb wQbdFlightJczb:wQbdFlightJczbList){
					wQbdFlightJczb.setTableName("W_QBD_FLIGHT_JCZB_BAK");
					ZhiLiangConst.addCommonFields(wQbdFlightJczb);
					wQbdFlightJczb.setStatus(HAIR_DOWN_MAP.get(GROUP_ALREADY_SEND3));
					wQbdFlightJczb.setReportStatus(ZhiLiangConst.REPORT_STATUS_GROUPTOBEREPORTED);
					wQbdFlightJczbService.add(wQbdFlightJczb);
				}
			}
			SysAuditThreadLocalHolder.putParamerter("success", true);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
		}
		return  isSuccess ? success("下发成功！")
				: fail("下发失败！");
	}

	/**
	 * 保存飞行试验计划下发的数据
	 * @param map 反馈model
	 */
	public ResultData saveWebFeedJhDate(Map map) throws Exception{
		ObjectMapper objectMapper = new ObjectMapper();
		List<WQbdFlightJc> allList = objectMapper.readValue(map.get("list").toString(), new TypeReference<List<WQbdFlightJc>>(){});
		allList.forEach(a->{
			a.setStatus(HAIR_DOWN_MAP.get(GROUP_ALREADY_SEND3));
		});
        wQbdFlightJcService.updateStatus(allList);
		return ResultData.success("操作成功！");
	}
	/**
	 * 功能描述: 跳转到导入页面
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/import")
	@Action(description = "跳转到飞行试验奖惩管理导入页面", exectype = "页面跳转日志")
	public String viewImport() {
		return "wQbdFlightJc/import";
	}


	/**
	 * 功能描述: 跳转到导出选择字段页面
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/export")
	@Action(description = "跳转到质量问题导出选择字段页面", exectype = "页面跳转日志")
	public String export(HttpServletRequest request, ModelMap modelMap) throws Exception {
		com.alibaba.fastjson.JSONObject jsonObject = AuxiliaryUtil.resolverModel(WQbdFlightJc.class);
		modelMap.put("tableInfo", jsonObject.toString());
		return "expImp/add";
	}

	/**
	 * 功能描述: 导出飞行试验奖惩管理数据信息
	 *
	 * @param: [request] http请求
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping("/exportData")
	@Action(description = "导出飞行试验奖惩管理数据信息", detail = "导出飞行试验奖惩管理数据信息<#if success>成功<#else></#if>")
	public void export(HttpServletRequest request, HttpServletResponse response) throws Exception {
		SysAuditThreadLocalHolder.putParamerter("success", false);
		String[] id = RequestUtil.getStringAryByStr(request, "id");
		QueryFilter queryFilter = new QueryFilter(request, false);
		JSONArray dataArray = ZhiLiangConst.exportAddConditions(queryFilter,id);
		List<WQbdFlightJc> wQbdFlightJcs = this.wQbdFlightJcService.queryAll(queryFilter);
		if (wQbdFlightJcs.isEmpty()) {
			wQbdFlightJcs.add(new WQbdFlightJc());
		}
		new AbstractExpUtil() {
			@Override
			public String customAnalysis(String fieldName, String fieldValue) {
				return null;
			}
		}.executeExport(request, response, wQbdFlightJcs, dataArray,
				AbstractExpUtil.ExpStyle.MANY_SHEET);
		SysAuditThreadLocalHolder.putParamerter("success", true);
	}

	//---------------------------------------------飞行试验奖惩进度----------------------------开始

	/**
	 * 功能描述: 跳转到导出选择字段页面
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/processExport")
	@Action(description = "跳转到质量问题导出选择字段页面", exectype = "页面跳转日志")
	public String processExport(HttpServletRequest request, ModelMap modelMap) throws Exception {
		com.alibaba.fastjson.JSONObject jsonObject = AuxiliaryUtil.resolverModel(WQbdFlightJc.class, 1);
		modelMap.put("tableInfo", jsonObject.toString());
		return "expImp/add";
	}

	/**
	 * 功能描述: 导出飞行试验奖惩进度管理数据信息
	 *
	 * @param: [request] http请求
	 * @return: java.lang.Object
	 * @auther: 于金
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping("/processExportData")
	@Action(description = "导出飞行试验奖惩进度管理数据信息", detail = "导出飞行试验奖惩进度管理数据信息<#if success>成功<#else></#if>")
	public void processExportData(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SysAuditThreadLocalHolder.putParamerter("success", false);
		String[] id = RequestUtil.getStringAryByStr(request, "id");
		QueryFilter queryFilter = new QueryFilter(request, false);
		JSONArray dataArray = ZhiLiangConst.exportAddConditions(queryFilter,id);
		List<WQbdFlightJc> wQbdFlightJcs = this.wQbdFlightJcService.queryAllByParams(queryFilter);
		if (wQbdFlightJcs.isEmpty()) {
			wQbdFlightJcs.add(new WQbdFlightJc());
		}
		new AbstractExpUtil() {
			@Override
			public String customAnalysis(String fieldName, String fieldValue) {
				return null;
			}
		}.executeExport(request, response, wQbdFlightJcs, dataArray,
				AbstractExpUtil.ExpStyle.MANY_SHEET);
		SysAuditThreadLocalHolder.putParamerter("success", true);
	}

	/**
	 * 功能描述: 跳转到反馈页面
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/feedback")
	@Action(description = "跳转到飞行试验奖惩进度管理反馈页面", exectype = "页面跳转日志")
	public String feedback(HttpServletRequest request, ModelMap modelMap) {
		String id = RequestUtil.getString(request, "id");
		modelMap.put("id", id);
		ISysUser sysUser = ContextUtil.getCurrentUser();
		SysOrg sysOrg = (SysOrg) ContextUtil.getCurrentOrg();
		modelMap.put("fillman", sysUser.getFullName());
		modelMap.put("fillmanAccount", sysUser.getAccount());
		modelMap.put("fillDept", sysOrg.getOrgName());
		modelMap.put("fillDeptId", sysOrg.getOrgId());
		modelMap.put("fillDate", new Date());
		return "wQbdFlightJc/feedback";
	}

	/**
	 * 功能描述: 获取反馈数据
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping("/getFeedbackData")
	@ResponseBody
	@Action(description = "查询飞行试验奖惩进度管理反馈数据", detail = "查询数据信息<#if success>成功<#else></#if>")
	public ResultData getFeedbackData(HttpServletRequest request) {
		SysAuditThreadLocalHolder.putParamerter("success", false);
		String id = RequestUtil.getString(request, "id");
		WQbdFlightJczb wQbdFlightJczb = wQbdFlightJcService.getFeedbackData(id);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return getResultDataSuccess("get.success", wQbdFlightJczb);
	}

	/**
	 * 功能描述: 保存反馈数据
	 *
	 * @return: java.lang.String
	 * @auther: hw
	 * @date: 2019-12-25 19:21:40
	 */
	@RequestMapping("/saveFeedbackDate")
	@ResponseBody
	@Action(description = "保存飞行试验奖惩进度反馈数据", detail = "编辑飞行试验奖惩进度反馈数据<#if success>成功<#else>失败</#if>")
	public ResultData saveFeedbackDate(@RequestBody WQbdFlightJczb feedBack) throws Exception {
		SysAuditThreadLocalHolder.putParamerter("success", false);
		//这里不用调用接口呢，因为要上报去做接口对接。
		ZhiLiangConst.updateCommonFields(feedBack);
		feedBack.setTableName("W_QBD_FLIGHT_JCZB");
		feedBack.setReportStatus(ZhiLiangConst.getDataInitStatusToHospital());
		wQbdFlightJczbService.update(feedBack);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return getResultDataSuccess("save.success");
	}

	/**
	 * 功能描述: 奖惩进度的院级list
	 *
	 * @return: java.lang.String
	 * @auther: sun
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/processList")
	@Action(description = "跳转到飞行试验奖惩管理首页", exectype = "页面跳转日志")
	public String viewProcessList(ModelMap modelMap) {
		modelMap.put("ztdwmcList", JSON.toJSONString(getOriginOrgToDicList()));
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
		BaseUtil.SystemLevel currentSystemLevel = BaseUtil.getCurrentSystemLevel();
		if (currentSystemLevel.equals(SystemLevel.GROUPLEVEL)) {
			return "wQbdFlightJc/processList";
		}
		return "wQbdFlightJc/secondList";

	}

	/**
	 * 功能描述: 奖惩进度院级list数据
	 *
	 * @param: [request] http请求
	 * @return: java.lang.Object
	 * @auther: sun
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping("/processList")
	@ResponseBody
	@Action(description = "附带检索条件的分页查询飞行试验奖惩管理", detail = "查询数据信息<#if success>成功<#else></#if>")
	public Object processList(HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, true);
		queryFilter.addFilter("status", HAIR_DOWN_MAP.get(GROUP_ALREADY_SEND3));

		//分页数据
//		List<WQbdFlightJc> pageDatas = wQbdFlightJcService.queryList(queryFilter);
		List<Map> pageDatas = wQbdFlightJcService.getAllToSubTableList(queryFilter);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return success(pageDatas, queryFilter.getPageBean().getTotalCount());
	}
	//---------------------------------------------飞行试验奖惩进度----------------------------结束

	/**
	 * 功能描述: 根据主键ID审减飞行试验奖惩管理数据
	 *
	 * @param: id 参数名称必须是"id"
	 * @return: java.lang.Object
	 * @auther: 米利昊
	 * @date: 2020-06-11 16:34:07
	 */
	@PostMapping("sj")
	@ResponseBody
	@Action(description = "根据主键ID审减飞行试验奖惩管理数据", exectype = "审减日志", detail = "审减数据信息<#if success>成功<#else>失败</#if>")
	public Object sj(@RequestParam("id") String id) {
		if (StringUtil.isEmpty(id)) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return fail("审减失败！");
		}
		WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(id);
		if (Objects.nonNull(wQbdFlightJc.getStatus())
				&& !HAIR_DOWN_MAP.get(GROUP_PREPARE_SEND).equals(wQbdFlightJc.getStatus())) {
			SysAuditThreadLocalHolder.putParamerter("success", false);
			return fail("审减失败，只允许审减待下发的数据");
		}
		wQbdFlightJc.setStatus(HAIR_DOWN_MAP.get(GROUP_REVIEW));
		int result = wQbdFlightJcService.updateBySj(wQbdFlightJc);
		if (result > 0) {
			SysAuditThreadLocalHolder.putParamerter("success", true);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
		}
		return result > 0 ? success("审减成功！")
				: fail("审减失败！");
	}

	/**
	 * 功能描述: 附带检索条件的分页查询
	 *
	 * @param :[request] http请求
	 * @return :java.lang.Object
	 * @auther :米利昊
	 * @date :2020-06-15 10:11
	 */
	@RequestMapping("/groupList")
	@ResponseBody
	@Action(description = "集团附带检索条件的分页查询飞行试验奖惩管理", detail = "查询数据信息<#if success>成功<#else></#if>")
	public Object groupList(HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, true);
		//分页数据
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WQbdFlightJcGroupVo> pageData = wQbdFlightJcService.groupList(queryFilter);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		pageData.stream().forEach(wQbdFlightJcGroupVo -> {
			try {
				xhmcList.forEach(a -> {
					if (a.getItemValue().equals(wQbdFlightJcGroupVo.getXhmc())) {
						wQbdFlightJcGroupVo.setXhmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		//总体单位名称
		List<Dictionary> ztdwmcList = getOriginOrgToDicList();
		pageData.stream().forEach(wQbdFlightJcGroupVo -> {
			try {
				ztdwmcList.forEach(a -> {
					if (a.getItemValue().equals(wQbdFlightJcGroupVo.getZtswmc())) {
						wQbdFlightJcGroupVo.setZtswmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});


		return success(pageData, queryFilter.getPageBean().getTotalCount());
	}

	/**
	 * 功能描述: 奖惩进度的二级list
	 *
	 * @return: java.lang.String
	 * @auther: sun
	 * @date: 2020-05-25 16:46:07
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/secondList")
	@Action(description = "跳转到飞行试验奖惩管理首页", exectype = "页面跳转日志")
	public String viewSecondList(ModelMap modelMap) {
		modelMap.put("ztdwmcList", JSON.toJSONString(getOriginOrgToDicList()));

		List<WQbdXhdh> xhdhList = wQbdXhdhService.getAll();
		modelMap.put("xhdhList", JSON.toJSONString(xhdhList));
		return "wQbdFlightJc/secondList";
	}


	/**
	 * 功能描述: 附带检索条件的分页查询
	 *
	 * @param :[request] http请求
	 * @return :java.lang.Object
	 * @auther :米利昊
	 * @date :2020-06-15 10:11
	 */
	@RequestMapping("/secondList")
	@ResponseBody
	@Action(description = "二级单位附带检索条件的分页查询飞行试验奖惩管理", detail = "查询数据信息<#if success>成功<#else></#if>")
	public Object secondList(HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, true);
		//分页数据
		ZhiLiangConst.addQueryFilter(queryFilter);

		List<WQbdFlightJcLevelSecondVo> pageData = wQbdFlightJcService.secondList(queryFilter);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		pageData.stream().forEach(wQbdFlightJcLevelSecondVo -> {
			try {
				wQbdFlightJcLevelSecondVo.setReportStatusStr(
						ZhiLiangConst.getStatusStrByInt(wQbdFlightJcLevelSecondVo.getReportStatus()));
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		});
		try {
			ZhiLiangConst.showName(pageData);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		ZhiLiangConst.isDataAllowEdit(pageData, true);
		List<Dictionary> xhmcList = getXhdhToDicList();
		pageData.stream().forEach(wQbdFlightJcLevelSecondVo -> {
			try {
				xhmcList.forEach(a -> {
					if (a.getItemValue().equals(wQbdFlightJcLevelSecondVo.getXhmc())) {
						wQbdFlightJcLevelSecondVo.setXhmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

		return JSON
				.toJSONStringWithDateFormat(success(pageData, queryFilter.getPageBean().getTotalCount()),
						"yyyy-MM-dd");
	}

	/**
	 * 2020-6-16 zzy
	 * 飞行试验奖惩进度管理明细页
	 * @param request
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/particularsprocess")
	@Action(description = "跳转到飞行试验奖惩进度详情页面", exectype = "页面跳转日志")
	public Object viewProcessParticulars(HttpServletRequest request,ModelMap modelMap){
		String id = RequestUtil.getString(request, "id");
		modelMap.put("id", id);
		QueryFilter queryFilter = new QueryFilter(request,false);
		ZhiLiangConst.addQueryFilter(queryFilter);
		List<WFlightRewardsProjectVo> Projects = wFlightRewardsProjectService.getFxsymcList(queryFilter);
		modelMap.put("projectList", JSON.toJSONString(Projects));
		// 密级
		setDicToModelMap("mj", modelMap);
		//型号名称
//		setDicToModelMap("xhmc", modelMap);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		modelMap.put("xhmcList", JSON.toJSONString(xhmcList));
		//项目类型
		setDicToModelMap("xmlx", modelMap);
		//总体单位名称
		setDicToModelMap("ztdwmc", modelMap);
		//项目类别
		setDicToModelMap("xmlb", modelMap);
		//项目阶段
		setDicToModelMap("xmjd", modelMap);
		//主管部门
		setDicToModelMap("zgbm", modelMap);
		//单位类别
		setDicToModelMap("dwlb", modelMap);

        String isClose = RequestUtil.getString(request, "isClose");
        modelMap.put("isClose", isClose);

		return "wQbdFlightJc/particulars_process";
	}


	/**
	 * 2020-6-16 zzy
	 * 获取单条奖惩进度数据,包含子表数据,用于飞行试验奖惩进度管理明细页回显
	 * @param request
	 * @param modelMap
	 * @return
	 */
	@GetMapping("/getJCDataByid")
	@ResponseBody
	@Action(description="根据主键id查询飞行试验奖惩管理的一条数据",detail="根据主键id查询飞行试验奖惩管理的数据<#if success>成功<#else>失败</#if>")
	public Object getJCDataByid(HttpServletRequest request, ModelMap modelMap) {
		String id = RequestUtil.getString(request, "id");
		//2020/7/2 zzy 如果是集团的,传入的id是主数据的id...
		WQbdFlightJc jcdata;
		if (BaseUtil.getCurrentSystemLevel()== SystemLevel.GROUPLEVEL) {
			jcdata= wQbdFlightJcService.getOneById(id);
			if (null==jcdata) {
				SysAuditThreadLocalHolder.putParamerter("success", false);
				return getResultDataError("get.failure");
			}
			Map<String,Object> paramMap= Maps.newHashMap();
			paramMap.put("refId",id);
			paramMap.put("tableName","W_QBD_FLIGHT_JCZB_BAK");
			List<WQbdFlightJczb> zblist = wQbdFlightJczbService.getListByRefId(paramMap);
			if (null != zblist && zblist.size() > 0) {
				jcdata.setwQbdFlightJczbList(zblist);
			}
		}
		else{
			WQbdFlightJczb wQbdFlightJczb = wQbdFlightJczbService.getOneById(id);
			if (null == wQbdFlightJczb) {
				SysAuditThreadLocalHolder.putParamerter("success", false);
				return getResultDataError("get.failure");
			}
			//获取关联的主表数据
			jcdata = wQbdFlightJcService.getOneById(wQbdFlightJczb.getRefid());
			if (null == jcdata) {
				SysAuditThreadLocalHolder.putParamerter("success", false);
				return getResultDataError("get.failure");
			}
			List<WQbdFlightJczb> zblist = new ArrayList<>();
			zblist.add(wQbdFlightJczb);
			jcdata.setwQbdFlightJczbList(zblist);
		}
//		return getResultDataSuccess("get.success", jcdata);
		return JSON
				.toJSONStringWithDateFormat(getResultDataSuccess("get.success", jcdata), "yyyy-MM-dd");
	}

	/**
	 * 2020-6-17 mlh 飞行试验奖惩进度奖惩/处罚页面
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/rewardOrPunishment")
	@Action(description = "跳转到飞行试验奖惩进度奖励/处罚页面", exectype = "页面跳转日志")
	public String rewardOrPunishment(HttpServletRequest request, ModelMap modelMap) {
		String isReward = RequestUtil.getString(request, "isReward");
		String id = RequestUtil.getString(request, "id");
		modelMap.put("id", id);
		modelMap.put("isReward", isReward);
		modelMap.put("rewardOrPunishmentStr", "处罚");
		WQbdFlightJczb wQbdFlightJczb = wQbdFlightJczbService.getOneById(id);
		WQbdFlightJc wQbdFlightJc = wQbdFlightJcService.getOneById(wQbdFlightJczb.getRefid());
		List<Dictionary> xhmcList = getXhdhToDicList();
		for (Dictionary dictionary : xhmcList) {
			if (dictionary.getItemValue().equals(wQbdFlightJc.getXhmc())) {
				wQbdFlightJc.setXhmc(dictionary.getItemName());
			}
		}
		modelMap.put("wQbdFlightJc", wQbdFlightJc);
		modelMap.put("wQbdFlightJczb", wQbdFlightJczb);
		modelMap.put("amount", wQbdFlightJczb.getSjcfed());
		if (isReward.equals("1")) {
			modelMap.put("rewardOrPunishmentStr", "奖励");
			modelMap.put("amount", wQbdFlightJczb.getSjjled());
		}

		List<Dictionary> originOrgToDicList = extendSysOrgService.getSubordinateUnits();
		modelMap.put("orgList", JSON.toJSONString(originOrgToDicList));
		return "wQbdFlightJc/rewardOrPunishment";
	}

	/**
	 * 2020-6-17 mlh 飞行试验奖惩进度奖惩/处罚页面
	 */
	@RequestMapping("/getListByRefId")
	@ResponseBody
	@Action(description = "根据进度主键获取奖惩记录", detail = "查询数据信息<#if success>成功<#else></#if>")
	public Object getListByRefId(HttpServletRequest request) {
		SysAuditThreadLocalHolder.putParamerter("success", false);
		String id = RequestUtil.getString(request, "id");
		List<WQbdFlightJcjlcf> wQbdFlightJcjlcfList = wQbdFlightJcjlcfService.getListByRefId(id);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return success(wQbdFlightJcjlcfList);
	}

	/**
	 * 功能描述:  数据保存通用方法
	 *
	 * @param: wQbdFlightJc 保存的对象
	 * @return: java.lang.Object
	 * @auther: 米利昊
	 * @date: 2020-06-18 16:46:07
	 */
	@RequestMapping(UrlConstants.MODULE_FUNCTION_SAVE + "Jcjlcf")
	@ResponseBody
	@Action(description = "保存飞行试验奖惩数据", detail = "<#if isAdd>新增<#else>编辑</#if>飞行试验奖惩管理数据<#if success>成功<#else>失败</#if>")
	public Object saveJcjlcf(@RequestBody WQbdFlightJcjlcfParamVo wQbdFlightJcjlcfParamVo) {
		int result = wQbdFlightJcjlcfService.save(wQbdFlightJcjlcfParamVo);
		if (result > 0) {
			SysAuditThreadLocalHolder.putParamerter("success", true);
		} else {
			SysAuditThreadLocalHolder.putParamerter("success", false);
		}
		return result > 0 ? getResultDataSuccess("save.success") : getResultDataError("save.failure");
	}

	/**
	 * 查询上报的信息
	 *
	 * @param request
	 * @param id
	 * @param tableName
	 * @return
	 */
	@RequestMapping("/reportList")
	@ResponseBody
	@Action(description = "保存飞行试验奖惩数据", detail = "<#if isAdd>新增<#else>编辑</#if>飞行试验奖惩管理数据<#if success>成功<#else>失败</#if>")
	public Object reportList(HttpServletRequest request, @RequestParam("id") String id, @RequestParam("tableName") String tableName) {
		//业务数据
		List<WQbdFlightJc> reportList = wQbdFlightJcService.reportList(id, tableName);
		//型号名称
		List<Dictionary> xhmcList = getXhdhToDicList();
		reportList.stream().forEach(wQbdFlightJc -> {
			try {
				xhmcList.forEach(a->{
					if(a.getItemValue().equals(wQbdFlightJc.getXhmc())){
						wQbdFlightJc.setXhmc(a.getItemName());
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return getResultDataSuccess("options.success", reportList);
	}
	/**
	 * 查询是否有上报资格
	 *
	 * @param ids id集合
	 * @return
	 */
	@RequestMapping("/judgeReport")
	@ResponseBody
	@Action(description = "查询是否有上报资格")
	public Object judgeReport(String ids) {
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return wQbdFlightJczbService.judgeReport(ids);
	}


}
